package demo.multithreading;

/**
 * 存钱
 * @author small瑞
 */
public class PutMoney extends Thread{
    Amount amount;


    public PutMoney(String name, Amount amount) {
        super(name);
        this.amount = amount;
    }

    @Override
    public void run() {
        while (true) {
            synchronized (amount) {
                System.out.println("工资到账~~~");
                amount.setHave(true);
                try {
                    amount.wait();
                } catch (InterruptedException e) {
                    e.printStackTrace();
                }
                amount.notifyAll();
            }

        }
    }
}
